package com.imooc.security.demo.other;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 模拟 队列+应用2
 * @author JackYang
 * @description:
 * @create: 2020/6/14 13:23
 */
@Component
public class MockQueue {
    private String placeOrder;
    private String completeOrder;
    private Logger logger = LoggerFactory.getLogger(getClass());
    
    public void setPlaceOrder(String placeOrder) throws Exception {
        //模拟应 用2 收到队列消息后 开启一个线程进行处理
        new Thread(()->{
            logger.info("接到下单请求"+placeOrder);
            try {
                Thread.sleep(1500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            this.completeOrder=placeOrder;
           logger.info("下单请求处理完毕"+placeOrder);
        }).start();
    }
    
    public String getPlaceOrder() {
        return placeOrder;
    }
    
    public String getCompleteOrder() {
        return completeOrder;
    }
    
    public void setCompleteOrder(String completeOrder) {
        this.completeOrder = completeOrder;
    }
}
